package beans {
	
	public class LoginBean {

		//------------------------------------------------------------
		//
		// variables
		//
		//------------------------------------------------------------
		
		//------------------------------
		// userName
		//------------------------------

		private var _userName:String;

		public function get userName():String {
			return _userName;
		}

		public function set userName(userName:String):void {
			_userName = userName;
		}
	
		//------------------------------
		// password
		//------------------------------

		private var _password:String;

		public function get password():String {
			return _password;
		}

		public function set password(password:String):void {
			_password = password;
		}
	
		//------------------------------
		// validationCode
		//------------------------------

		private var _validationCode:String;

		public function get validationCode():String {
			return _validationCode;
		}

		public function set validationCode(validationCode:String):void {
			_validationCode = validationCode;
		}
	
		//------------------------------------------------------------
		//
		// constructor
		//
		//------------------------------------------------------------
		
		public function LoginBean(value:XML) {
			if (!value) {
				userName = "";
				password = "";
				validationCode = "";
				return;
			}
			
			userName = value.data.userName;
			password = value.data.password;
			validationCode = value.data.validationCode;
		}
		
		/**
		 * represent this object as a xml object
		 * @return the string format of the xml object
		 */
		public function toXMLString():String {
			var rootNode:XML = <results/>;
			
			var dataNode:XML = <data/>;
			rootNode.appendChild(dataNode);
			
			var userNameNode:XML = <userName>{userName}</userName>;
			dataNode.appendChild(userNameNode);
			
			var passwordNode:XML = <password>{password}</password>;
			dataNode.appendChild(passwordNode);
			
			var validationCodeNode:XML = <validationCode>{validationCode}</validationCode>;
			dataNode.appendChild(validationCodeNode);
			return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + rootNode.toXMLString();
		}

	}
}